//
//  ExCustomPresentViewController.m
//  OC-Example
//
//  Created by apang on 2018/7/31.
//  Copyright © 2018年 apang.men All rights reserved.
//

#import "ExCustomPresentViewController.h"
#import "ExCustomPresentAnimation.h"
#import "ExCustomModelViewController.h"
@interface ExCustomPresentViewController ()<ModalViewControllerDelegate,UIViewControllerTransitioningDelegate>
{
    ExCustomPresentAnimation *customPresentAnimation;
}
@end

@implementation ExCustomPresentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view setBackgroundColor:[UIColor whiteColor]];
    self.title = @"自定义模态动画";
    UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
    [button setFrame:CGRectMake(0, 0, 100, 40)];
    [button setTitle:@"跳转" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
    button.center = self.view.center;
    [self.view addSubview:button];
    customPresentAnimation = [[ExCustomPresentAnimation alloc] init];
}

- (void)buttonClick {
    ExCustomModelViewController * modelVC = [[ExCustomModelViewController alloc] init];
    modelVC.delegate = self;
    modelVC.transitioningDelegate = self;
    [self presentViewController:modelVC animated:YES completion:nil];
}

-(void)modalViewControllerDidClickedDismissButton:(ExCustomModelViewController *)viewController
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
    return customPresentAnimation;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
